home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / asmutil / 80x0393.zip / COPPER.DOC < prev    next >
Text File  |  1992-09-30  |  2KB  |  75 lines

  1. By Craig Allsop
  2.  
  3. I figured I might as well give everyone the macros from my source that 
  4. display the copper bars.  (They were  written for Tasm,  Ideal  mode - 
  5. but are easily converted) - I reveal all!
  6.  
  7. macro   waithorz                ; DX = 3DAh!
  8.         local   a,b
  9. a:      in      al,dx
  10.         rcr     al,1
  11.         jc      a
  12. b:      in      al,dx
  13.         rcr     al,1
  14.         jnc     b
  15. endm
  16.  
  17. macro   waitvert
  18.         local   a,b
  19. a:      in      al,dx
  20.         test    al,8
  21.         jnz     a
  22. b:      in      al,dx
  23.         test    al,8
  24.         jz      b
  25. endm
  26.  
  27. macro   copper                  ; SI = Colour table, CX = # of Colours
  28.         local   a               ; BL = Palette to change
  29.         mov     ah,0c9h
  30.         mov     dl,3
  31. a:      mov     dl,0c8h
  32.         mov     al,bl
  33.         out     dx,al           ; Select palette
  34.         inc     dl
  35.         outsb
  36.         outsb                   ; Send first 2 values
  37.         lodsb                   ; Get next one ready
  38.         mov     bh,al           ; and hang onto it
  39.         mov     dl,0dah
  40.         waithorz                ; Wait for the horz. retrace
  41.         mov     dl,ah
  42.         mov     al,bh
  43.         out     dx,al           ; Send last value (Causes static!)
  44.         dec     cx
  45.         jnz     a               ; Continue...
  46. endm
  47.  
  48.  
  49. To use them, requires a 'waitvert' before using 'copper' to execute it, 
  50. and 'waitvert' requires dx = 3dah. Simple really. Eg:
  51.  
  52.         mov     si, <address of palette>
  53.         mov     cx, <number of colours/lines>
  54.         mov     bl, <palette to change>
  55.         mov     dx, 3dah
  56.         waitvert
  57.         copper
  58.  
  59. You will notice that I send two values before waiting for the retrace, 
  60. because the  VGA only loads them into a buffer,  and only updates  the 
  61. palette registers when it gets the last value,  which is also when you 
  62. get the static 'dot' appearing on the screen.  Since I'm doing it this 
  63. way,  on slow machines it works perfectly,  and on faster machines you 
  64. get static on the right side  of the  screen,  but you can  remove the 
  65. overscan on the right side to fix that problem.
  66.  
  67. Regards,
  68. Craig.
  69.  
  70. If anyone uses the above macros, or modify the above code for suitable
  71. functions in another lanugage, then be my guest,but please give credit 
  72. where its due, and mention my name  or my alias  'Daemon' - the  above 
  73. macros must conatin this paragraph in any source and are Public Domain 
  74. in all other respects.
  75.